<%@ page language="java" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
${aier_doctype}
<html <s:property value="aier_html_xmlns" escape="false"/>>
<head>
<meta http-equiv="Content-Type" content="${aier_content_type}" />
<meta name="keywords" content="${aier_keyworks}" />
<meta name="description" content="${aier_description}" />
<title>${aier_title}</title>
<link rel="stylesheet" href="${aier_css_url}${aier_jqui_css}ui.css" />
<link rel="Stylesheet" href="${aier_css_url}jq/jq.css" />
<link rel="stylesheet" href="${aier_css_url}social/module/reset.css" />
<link rel="Stylesheet" href="${aier_css_url}social/module/emotion.css" />
<link rel="stylesheet" href="${aier_css_url}social/module/jq-msg.css" />
<link rel="stylesheet" href="${aier_css_url}social/module/reset.css" />
<link rel="stylesheet" href="${aier_css_url}social/module/uploadphoto.css" />
<link rel="stylesheet" href="${aier_css_url}social/module/homeside.css" />
<link rel="stylesheet" href="${aier_css_url}social/user/homeforums/homeforums.css" />


<script type="text/javascript" src="${aier_js_url}j.js"></script>
<script type="text/javascript" src="${aier_js_url}b.js"></script>
<script type="text/javascript" src="${aier_js_url}jp/msg.js"></script>
<script type="text/javascript" src="${aier_js_url}97/WdatePicker.js"></script>
<script type="text/javascript" src="${aier_js_url}jq/cn.js"></script>
<script type="text/javascript" src="${aier_js_url}jq/jq.js"></script>
<script type="text/javascript" src="${aier_js_url}lib/block.js"></script>
<script type="text/javascript" src="${aier_js_url}lib/afu.js"></script>
<script type="text/javascript"
	src="${aier_js_url}emotion/xxsemotion.2.js"></script>
<script type="text/javascript" src="${aier_js_url}trantime/jquery-aier.js"></script>
</head>
<body>

	<!-- 顶栏 -->
	<s:action name="userhomecomm_homeHead" namespace="/user" executeResult="true"></s:action>
	<!-- 顶栏结束 -->

	<div class="window-content">

		<!-- wrap  -->

		<div class="wrap wrap-homepage wrap-tri-col hasgap clearfix">

			<s:action name="userhomecomm_homeLeft" namespace="/user"
				executeResult="true"></s:action>

			<!-- 主区域 (右  -->
			<div class="main-area clearfix">

				<!-- 中间栏 -->
				<div class="message-stream">

					<div class="post-fresh-news">
						<div class="hello-sentense">有什么亲子趣事想告诉大家？</div>

						<div class="textarea-box">
							<textarea name="" id="xxsTextarea" cols="30" rows="10"></textarea>
						</div>

						<div class="bottom-bar clearfix">

							<div class="functions">
								<a class="btn btn-emotion">
									<em class="icon-1 icon-1-emotion"></em><span>表情</span> 
								</a> 
								<a class="btn btn-photo" id="uploadPhoto">
									<em class="icon-1 icon-1-picture"></em><span>图片</span>
								</a>
							</div>

							<div class="xxs-submit">
								<a href="javascript:void(0);" class="btn btn-fabu"> <em id = "publish"
									class="icon-1 icon-1-fabu"></em> </a>
							</div>
						</div>
					</div>



					<div class="message-stream-list child-message-list clearfix" id="freshList">

						<!-- 1 一条新鲜事 -->

						<div class="xxs-item">
							<!-- 隐藏该条新鲜事 -->
							<div class="xxs-screen">
								<a>x</a>
								<div></div>
							</div>
							<!-- 头像 -->
							<div class="xxs-avatar">
								<a class="xxs-avatar-mask"><img
									src="${aier_img_url}temp/avatar/1.jpg" alt=""> </a>
							</div>
							<!-- 内容 -->
							<div class="xxs-detail">
								<!-- 昵称 -->
								<div class="xxs-name">
									<a>化成雨</a>
								</div>
								<!-- 文本 -->
								<div class="xxs-text">
									我越来越不爱看“热门微博”都是些重复的内容，而且有的热门一点内容都没有，也不知道为什么顶这么高。</div>

								<!-- ul 预览列表 默认显示,ajax后隐藏,extend隐藏后再显示-->
								<ul class="xxs-media-pre xxs-single-img" style="">

									<li>
										<!-- 单张图片 -->
										<div>
											<img class="zoom-in"
												src="${aier_img_url}temp/userCenter/user-123-avatar.png"
												alt="">
										</div>
									</li>
								</ul>

								<!-- 完整列表  默认没有,ajax后加载并显示,再次点击隐藏 -->
								<div class="xxs-box xxs-extend" style="display:none">
									<p>
										<a>收起</a>
									</p>
									<div class="media">
										<img class="zoom-out"
											src="${aier_img_url}temp/userCenter/user-123-avatar.png"
											alt="">
									</div>
								</div>

								<!-- 底部功能 -->
								<div class="xxs-function clearfix">
									<div class="xxs-handle">
										<a>赞</a> <em>|</em> <a>转发(1)</a> <em>|</em> <a
										>收藏</a> <em>|</em> <a>评论(1)</a>
									</div>
									<div class="xxs-from">
										<a>7月11日 19:18</a> <em>来自</em> <a>WeicoPro
										</a>
									</div>
								</div>
							</div>


						</div>

						<!--  2end 原创结束,转发一条开始 -->
						<!--  3 -->

						<div class="xxs-item">
							<!-- 隐藏该条新鲜事 -->
							<div class="xxs-screen">
								<a>x</a>
								<div></div>
							</div>
							<!-- 头像 -->
							<div class="xxs-avatar">
								<a class="xxs-avatar-mask"><img
									src="${aier_img_url}temp/avatar/1.jpg" alt=""> </a>
							</div>
							<!-- 内容 -->
							<div class="xxs-detail">
								<!-- 昵称 -->
								<div class="xxs-name">
									<a>化成雨</a>
								</div>
								<!-- 文本 -->
								<div class="xxs-text">
									我越来越不爱看“热门微博”都是些重复的内容，而且有的热门一点内容都没有，也不知道为什么顶这么高。</div>

								<!-- 完整列表
								默认没有,ajax后加载并显示,再次点击隐藏 -->
								<div class="xxs-box xxs-box-has-o" style="">
									<div class="xxs-name-o">
										<a>李笔可</a>
									</div>
									<div class="text">我的名字叫利比克,你可以叫我春哥或是曾哥</div>

									<!-- 从这里 -->
									<!-- ul 预览列表 默认显示,ajax后隐藏,extend隐藏后再显示-->
									<ul class="xxs-media-pre xxs-single-img" style="">
										<li>
											<div>
												<img class="zoom-in"
													src="${aier_img_url}temp/userCenter/user-123-avatar.png"
													alt="">
											</div>
										</li>
									</ul>


									<div class="xxs-extend" style="display:none">
										<p>
											<a class="xxs-btn-collapse">收起</a>
										</p>
										<div class="media">
											<img class="zoom-out"
												src="${aier_img_url}temp/userCenter/user-123-avatar.png"
												alt="">
										</div>




									</div>

									<!-- 出处的底部功能 -->
									<div class="xxs-function clearfix">
										<div class="xxs-handle">
											<a >赞</a> <em>|</em> <a >转发(1)</a> <em>|</em> <a
												>评论(1)</a>
										</div>
										<div class="xxs-from">
											<a >7月11日 19:18</a> <em>来自</em> <a >WeicoPro
											</a>
										</div>
									</div>



									<!-- 到这里，是原PO的，放在xxs-box里 -->


								</div>

								<!-- 底部功能 -->
								<div class="xxs-function clearfix">
									<div class="xxs-handle">
										<a >赞</a> <em>|</em> <a >转发(1)</a> <em>|</em> <a
											>收藏</a> <em>|</em> <a >评论(1)</a>
									</div>
									<div class="xxs-from">
										<a >7月11日 19:18</a> <em>来自</em> <a >WeicoPro
										</a>
									</div>
								</div>
							</div>


						</div>


						<!--  2end-->
						<!--  3 -->


						<div class="xxs-item">
							<!-- 隐藏该条新鲜事 -->
							<div class="xxs-screen">
								<a >x</a>
								<div></div>
							</div>
							<!-- 头像 -->
							<div class="xxs-avatar">
								<a class="xxs-avatar-mask" ><img
									src="${aier_img_url}temp/avatar/1.jpg" alt=""> </a>
							</div>
							<!-- 内容 -->
							<div class="xxs-detail">
								<!-- 昵称 -->
								<div class="xxs-name">
									<a >化成雨</a>
								</div>
								<!-- 文本 -->
								<div class="xxs-text">
									我越来越不爱看“热门微博”都是些@重复的内容，而且有的热门一点内容都没有，也不知道为什么顶这么高。</div>

								<!-- 完整列表
								默认没有,ajax后加载并显示,再次点击隐藏 -->
								<div class="xxs-box xxs-box-has-o" style="">
									<div class="xxs-name-o">
										<a>李笔可</a>
									</div>
									<div class="text">我的名字叫利比克,你可以叫我春哥或是曾哥</div>

									<!-- 从这里 -->
									<!-- ul 预览列表 默认显示,ajax后隐藏,extend隐藏后再显示-->
									<ul class="xxs-media-pre xxs-single-img" style="">
										<li>
											<!-- 九宫格 -->
											<div class="jiugongge">
												<ul>
													<li><img class="zoom-in"
														src="${aier_img_url}temp/userCenter/user-123-avatar.png"
														alt="">
													</li>
													<li><img class="zoom-in"
														src="${aier_img_url}temp/userCenter/11.jpg" alt="">
													</li>
													<li><img class="zoom-in"
														src="${aier_img_url}temp/userCenter/12.jpg" alt="">
													</li>
												</ul>
											</div>
										</li>
									</ul>


									<div class="xxs-extend" style="display:none">
										<p>
											<a class="btn-coll">收起</a>
										</p>
										<div class="media">
											<img id="changesrc" class="zoom-out"
												src="${aier_img_url}temp/userCenter/user-123-avatar.png"
												alt="">
										</div>




									</div>

									<!-- 出处的底部功能 -->
									<div class="xxs-function clearfix">
										<div class="xxs-handle">
											<a >赞</a> <em>|</em> <a >转发(1)</a> <em>|</em> <a
												>评论(1)</a>
										</div>
										<div class="xxs-from">
											<a >7月11日 19:18</a> <em>来自</em> <a >WeicoPro
											</a>
										</div>
									</div>



									<!-- 到这里，是原PO的，放在xxs-box里 -->

								</div>

								<!-- 底部功能 -->
								<div class="xxs-function clearfix">
									<div class="xxs-handle">
										<a >赞</a> <em>|</em> <a >转发(1)</a> <em>|</em> <a
											>收藏</a> <em>|</em> <a >评论(1)</a>
									</div>
									<div class="xxs-from">
										<a >7月11日 19:18</a> <em>来自</em> <a >WeicoPro
										</a>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
				
				<!-- 右栏 -->
				<s:action name="userhomecomm_homeRight" namespace="/user" executeResult="true"></s:action>
		
		
			</div>

				<!-- 回到顶部 -->
				<s:action name="userhomecomm_backToTop" namespace="/user" executeResult="true"></s:action>
				
		</div>
		<!-- footer copyright -->
		<s:action name="userhomecomm_homeFooter" namespace="/user" executeResult="true"></s:action>
		<!-- /footer copyright -->
	</div>
	
	
	<div id="uploadPhotoBox" style="display:none;">
		<div class="title">上传图片</div>

		<div class="select">

			<a class="btn-select">
				<label for="selectPhoto">
				<span>选择图片</span>
				</label>
			</a>

			<input type="file" id="selectPhoto" style="" name = "selectPhoto"/>
		</div>

		<div class="uploading" style="display:none">正在上传</div>

		<div id="confirmPhoto" style="display:none">
			<div id="photoName"></div>
			<div id="delete">x</div>
		</div>
				
				
				
	
	
	</div>
</body>
<script type="text/javascript">

// 上传图片

$("body").click(function(){
 	$("#uploadPhotoBox").hide();
});

$('#uploadPhoto,#uploadPhotoBox').click(function(event) {
    event.stopPropagation();
});

$("#uploadPhoto").click(function() {
//    if ( !$("#uploadPhotoBox").hasClass("open") ) {
//    	 $("#uploadPhotoBox").addClass("open");
//    }

//    if (!$('#uploadPhotoBox')[0]) {
//        $('body').append('<div id="uploadPhotoBox"></div>');
//    } else {
//    	$('#uploadPhotoBox').toggle();
 //   }
    $('#uploadPhotoBox').toggle();
    $('#uploadPhotoBox').css({
        top: $(this).offset().top + $(this).height() + 8,
        left: $(this).offset().left
    });
});


	$("#selectPhoto").live('change', function(){
		upfile();
		$(".select").hide();
		$(".uploading").show();
	});
	var imgName;
	function upfile() {
	    var temp = $('#selectPhoto').val().substring($('#selectPhoto').val().lastIndexOf('.')).toLowerCase();
		try {$.ajaxFileUpload({
			url : "${aier_url}commonjs/image_uploadImage${aier_suffix}?photoName="+temp+"&&imageUrl=${fresh_upload_url}&&type=1",
			secureuri : false,
			fileElementId : 'selectPhoto',
			dataType : 'json',
			success : function(data, status) {
			    if (data.s == 1) {
				    imgName = data.imageName;
	                $(".uploading").hide();
	                $('#confirmPhoto').show();
	                $('#photoName').html(imgName);
			    } else {
			        $().message("图片上传出错，请重新上传！");
			        $(".uploading").hide();
                    $('.select').show();
			    }
				
			},
			error : function(data, status, e) {
				$().message("服务器连接超时");
				
			}
		});
		} catch (e) {
			$(".uploading").hide();
			$('.select').show();
			$().message("服务器连接超时");
		}
	};
	
	// 删除图片
	$("#delete").click(function(){
       
         var fun=function(data){
            if(data.s==1){
                imgName = "";
                $('#confirmPhoto').hide();
                $('#selectPhoto').val("");
                $('.select').show();
            } else {
                $().message("删除失败，请稍后再试！"); 
            }
        };
        exeAjax(
             ajaxUrl("${aier_url}${aier_urijs}userhomeforums_deleteImage${aier_suffix}"),
             fun,{
                 "imageName":imgName
        });
	    
	});







// 图片上传结束

    // 解析表情
    $(document).ready(function() {
        $('.text,.xxs-text').each(function() {
            $(this).tranText();
        });
    });



	// 插入表情
	$('.btn-emotion').sinaEmotion({
		target : $('#xxsTextarea')
	});

	// 转换时间
	$(document).ready(function() {
		$('.msg-date').each(function() {
			$(this).text(tranTime($(this).attr('data-stamp')));
		});
	});

	// 预览图和完整图切换
	//缩小
	$('.zoom-out,.xxs-btn-collapse').click(
			function() {
				$(this).parents('.xxs-extend').css('display', 'none').prev('.xxs-media-pre').css('display', 'block');
			});
	//放大
	$('.zoom-in').click(
			function() {
				$(this).parents('.xxs-media-pre').css('display', 'none').next('.xxs-extend').css('display', 'block');
			});
			
    // 发布新鲜事
    $("#publish").click(
        function() {
            var content = $("#xxsTextarea").val();
            if ((null == content.trim() || content.trim() == "") && (imgName == null || imgName == "")) {
                $().message("请输入内容");
                return
            }
            var fun=function(data){
               if(data.s==1){
                   searchAllFresh();
                   $("#xxsTextarea").val("");
                   imgName = "";
                   $('#confirmPhoto').hide();
	               $('#selectPhoto').val("");
	               $('.select').show();
               } else {
                   $().message("发布失败，请稍后再试！"); 
               }
           };
           exeAjax(
                ajaxUrl("${aier_url}${aier_urijs}userhomeforums_publishFresh${aier_suffix}"),
                fun,{
                    "content":content,
                    "imageName":imgName,
                    "power":0
           });
        }
    );
    
    // 获取新鲜事列表
    function searchAllFresh() {
        
        var fun=function(data){
               if(data.s==1){
                   if (data.freshList != null) {
                       appendFresh(data.freshList,data.uid);
                   } 
               }
           };
           exeAjax(
                ajaxUrl("${aier_url}${aier_urijs}userhomeforums_searchAllFresh${aier_suffix}"),
                fun,{
                    "page":1,
                    "page_size":10
           });
    }
    
    function appendFresh(freshList,uid) {
        var html = "";
        for (var i=0; i<freshList.length; i++) {
            var fresh = freshList[i];
            
            if (uid == fresh.uid) {
                // 删除该条新鲜事 
                html += "<div class='xxs-item'><div class='xxs-screen'><a href=''>x</a><div></div></div>";
            } else {
                html += "<div class='xxs-item'><div class='xxs-screen' style='display: none;'><a href=''>x</a><div></div></div>";
            }
            
            // 头像
            html += "<div class='xxs-avatar'><a class='xxs-avatar-mask' href='${aier_url}user/uccomm_userCenter.shtml?in_uid="+fresh.uid+"'><img src=${get_picturl_url}small/"+fresh.headimg+" alt=''></a></div>";
            // 内容
            html += "<div class='xxs-detail'><div class='xxs-name'><a href=''>"+fresh.nickname+"</a></div>";
           
            if (fresh.type == 1) {
                html += "<div class='xxs-text'>转发</div>";
            } else {
                html += "<div class='xxs-text'>"+fresh.content+"</div>";
            }
            
            // 有图片
            if (null != fresh.img) {
                html += "<ul class='xxs-media-pre xxs-single-img' style=''><li><div><img href='${aier_url}user/uccomm_userCenter.shtml?in_uid="+fresh.uid+"' class='zoom-in' src=${fresh_get_url}small/"+
                    fresh.img+" alt=''></div></li></ul><div class='xxs-box xxs-extend' style='display:none'><p><a class='xxs-btn-collapse'>收起</a></p><div class='media'><img class='zoom-out' src=${fresh_get_url}big/"+
                    fresh.img+" alt=''></div></div>";
            }
            
            // 底部功能
            html += "<div class='xxs-function clearfix'><div class='xxs-handle'>";
            
            if (fresh.pflag == 1) {
                if (fresh.pcount == 0) {
                    html += '<a onclick="praise('+fresh.fid+',1)">取消赞</a>';
                } else {
                    html += '<a onclick="praise('+fresh.fid+',1)">取消赞('+fresh.pcount+')</a>';
                }
                
            } else {
                if (fresh.pcount == 0) {
                    html += '<a onclick="praise('+fresh.fid+',0)">赞</a>';
                } else {
                    html += '<a onclick="praise('+fresh.fid+',0)">赞('+fresh.pcount+')</a>';
                }
            }
            if (fresh.tcount == 0) {
                html += '<em>|</em> <a onclick="transmitFresh('+fresh.fid+')">转发</a> <em>|</em>';
            } else {
                html += '<em>|</em> <a onclick="transmitFresh('+fresh.fid+')">转发('+fresh.tcount+')</a> <em>|</em>';
            }
        
            if (fresh.fflag == 1) {
                html += '<a onclick="deleteFFByUid('+fresh.fid+')">取消收藏</a>';
            } else {
                html += '<a onclick="favoriteFresh('+fresh.fid+')">收藏</a>';
            }
            
            if (fresh.ccount == 0) {
                html += "<em>|</em> <a href=''>评论";
            } else {
                html += "<em>|</em> <a href=''>评论("+fresh.ccount+")";
            }
            
            html += "</a></div><div class='xxs-from'><a>"+fresh.cdate.split("T")[0]+" "+fresh.cdate.split("T")[1]+"</a></div></div></div></div>";
       
        }
        
        $("#freshList").html(html);
        // 解析表情
        $(document).ready(function() {
            $('.text,.xxs-text').each(function() {
                $(this).tranText();
            });
        });
        //放大
        $('.zoom-in').click(
            function() {
                $(this).parents('.xxs-media-pre').css('display', 'none').next('.xxs-extend').css('display', 'block');
            });
        //缩小
         $('.zoom-out,.xxs-btn-collapse').click(
                 function() {
                     $(this).parents('.xxs-extend').css('display', 'none').prev('.xxs-media-pre').css('display', 'block');
                 });
    }
    $(document).ready(function() {
        searchAllFresh();
    });
    
    // 称赞或取消赞（ptype为0赞1取消赞）
    function praise(fid,ptype) {
        
        var fun=function(data){
               if(data.s==1){
                   
                   if (ptype == 0) {
                       // 将赞改为取消赞
                       
                   } else {
                       // 将取消赞改为赞
                   }
                   
               }
           };
           exeAjax(
                ajaxUrl("${aier_url}${aier_urijs}userhomeforums_praiseFresh${aier_suffix}"),
                fun,{
                    "fid":fid,
                    "ptype":ptype
           });
    }
    
    // 收藏新鲜事
    function favoriteFresh(fid) {
        
        var fun=function(data){
               if(data.s==1){
                   
                   // 将收藏变为取消收藏
                   
               }
           };
           exeAjax(
                ajaxUrl("${aier_url}${aier_urijs}userhomeforums_favoriteFresh${aier_suffix}"),
                fun,{
                    "fid":fid
           });
    }
    
    // 取消收藏新鲜事
    function deleteFFByUid(fid) {
        
        var fun=function(data){
               if(data.s==1){
                   
                   // 将取消收藏变为收藏
                   
                   
               }
           };
           exeAjax(
                ajaxUrl("${aier_url}${aier_urijs}userhomeforums_deleteFFByUid${aier_suffix}"),
                fun,{
                    "fid":fid
           });
    }
    
    // 转发新鲜事
    function transmitFresh(fid) {
        // 弹出框
        
        var fun=function(data){
               if(data.s==1){
                   
                   // 刷新列表
                   searchAllFresh();
               }
           };
           exeAjax(
                ajaxUrl("${aier_url}${aier_urijs}userhomeforums_transmitFresh${aier_suffix}"),
                fun,{
                    "relativeid":relativeid
           });
    }
    
</script>
</html>